/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import persistance.Doctor;
import persistance.Username;

/**
 *
 * @author Andreea
 */
@Stateless
public class DoctorSessionBean implements DoctorSessionBeanRemote {
    @PersistenceContext(unitName = "FamilyDoctorAssistant-ejbPU")
    private EntityManager em;

    @Override
    public void addDoctor(String name, String specialty, String username, String password) {
        Doctor d=new Doctor();
        d.setName(name);
        d.setSpecialty(specialty);
        Username u=new Username();
        u.setUsername(username);
        u.setPassword(password);
        em.persist(u);
        em.persist(d);
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    public void persist(Object object) {
        em.persist(object);
    }
    
}
